/*
 * @Description:
 * @Author: 胡涛
 * @Date: 2023-06-06 09:27:18
 * @LastEditors: 胡涛
 * @LastEditTime: 2023-09-09 22:20:07
 */

import { defineStore } from "pinia";
import { ref } from "vue";

export const useDemoStore = defineStore("demo", () => {
  const title = ref("标题1111");

  const setTitle = (val: string) => {
    title.value = val;
  };

  const viewNumber = ref(0);

  const updateNumber = (num: number) => {
    viewNumber.value = num;
  };
  const addNumber = (num: number) => {
    viewNumber.value += num;
    console.log("viewNumber", viewNumber);
  };

  return {
    title,
    setTitle,
    viewNumber,
    updateNumber,
    addNumber,
    persist: {
      enabled: true,
      strategies: [{ storage: localStorage, key: "vite-vue-store-demo" }],
    },
  };
});
